{{- $commit := "b081f2ae9e011fd92fd23f6efa209601f5a20a01" }}
---
artifact: kruise-state-metrics
from: {{ $.Images.BASE_GOLANG_21_ALPINE_DEV }}
git:
  - add: /{{ $.ModulePath }}/modules/402-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
    to: /patches
    stageDependencies:
      install:
        - '**/*'
mount:
  - fromPath: ~/go-pkg-cache
    to: /go/pkg
shell:
  setup:
    - export GOPROXY={{ $.GOPROXY }} CGO_ENABLED=0 GOOS=linux GOARCH=amd64
    - git clone {{ $.SOURCE_REPO }}/openkruise/kruise-state-metrics.git
    - cd kruise-state-metrics
    - git checkout {{ $commit }}
    - find /patches -name '*.patch' -exec git apply {} \;
    - go mod tidy
    - go mod vendor
    - go build -mod=vendor -a -o /tmp/kruise-state-metrics main.go
    - chown -R 64535:64535 /tmp/kruise-state-metrics
    - chmod 0700 /tmp/kruise-state-metrics
---
image: {{ $.ModuleName }}/{{ $.ImageName }}
fromImage: common/distroless
import:
 - artifact: kruise-state-metrics
   add: /tmp/kruise-state-metrics
   to: /kruise-state-metrics
   before: setup
docker:
  ENTRYPOINT: ["/kruise-state-metrics"]
  USER: 64535
